package com.vlong.town.controller.server.index;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.vlong.town.controller.base.BaseController;

@RequestMapping("/rest/index")
@RestController
public class IndexRestController extends BaseController{

	
	 
    /**
     * 小程序接口(便民平台)
     * 加载首页操作图标信息
     * @return DataMessage
     */
    @ResponseBody
    @PostMapping("/loadIndex")
    public JSONArray loadIndex() {
        JSONArray jsonArray = new JSONArray();
        // 图标标题
        String[] ps = new String[]{
                "村镇公告",
                "便民服务",
                "政策规定",
                "文化推送",
                /*"房屋出租",*/
                "经验借鉴",
                "购销信息",
                "租售劳务",
                "信访举报"
        };
        String[] as = new String[]{
                "/notice",
                "/honour",
                "/policy",
                "/activity",
               /* "/house",*/
                "/insurance",
                "/goods",
                "/",
                "/comm"
        };
        for(int i = 0; i < ps.length; i++) {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("icon", "images/icon-" + (i+1) + ".png");
            jsonObject.put("a", as[i]+as[i]);
            jsonObject.put("p", ps[i]);
            jsonArray.add(jsonObject);
        }
        return jsonArray;
    }
    
    
    /**
     * 游客平台
     * 加载首页操作图标信息
     * @return DataMessage
     */
    @ResponseBody
    @PostMapping("/loadIndexTourist")
    public JSONArray loadIndexTourist() {
        JSONArray jsonArray = new JSONArray();
        // 图标标题
        String[] ps = new String[]{
                "体验旅游",
                "景点门票",
                "住宿预订",
                "餐饮预订",
                "本地特产",
                "公共场所",
                "旅游资讯",
                "投诉监督",
        };
        String[] as = new String[]{
                "/experienceTourism",
                "/tourist",
                "/hotel",
                "/activity",
                "/goods",
                "/goods",
                "/honour",
                "/comm"
        };
        for(int i = 0; i < ps.length; i++) {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("icon", "images/icon-" + (i+12) + ".png");
            jsonObject.put("a",as[i]+as[i]);
            jsonObject.put("p", ps[i]);
            jsonArray.add(jsonObject);
        }
        return jsonArray;
    }

}
